<?php

namespace app\admin\controller\expert;

use app\common\controller\Backend;
use fast\Tree;
use think\Cache;

/**
 *  加权分红管理
 *
 * @icon   fa fa-list
 * @remark 
 */
class WeightingTask extends Backend
{

    protected $searchFields = 'id,title';

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 列表
     */
    public function index()
    {
        //设置过滤方法
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            //如果发送的来源是Selectpage，则转发到Selectpage
            if ($this->request->request('keyField')) {
                return $this->selectpage();
            }
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $list_info = db("user_weighting_task uwt")
                ->join('user u', "uwt.user_id=u.id", "LEFT")
                ->field("uwt.*,u.nickname,u.avatar,u.mobile")
                ->where($where)
                ->order($sort, $order)
                ->paginate($limit);
            $list = $list_info->items();
            $total = $list_info->total();

            foreach ($list as $k => $v) {
                // exit(print_r($v));

                $list[$k]["avatar"] = $v["avatar"] ? cdnurl($v["avatar"], true) : letter_avatar($v["nickname"]);
                unset($list[$k]["password"]);
                unset($list[$k]["salt"]);
            }
            $result = array("total" => $total, "rows" => $list);
            return json($result);
        }
        return $this->view->fetch();
    }
}
